﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{
    /// <summary>
    /// 可以根据多个variable的条件值，选择gray
    /// </summary>
    [RequireComponent(typeof(UIGrayscale))]
    [AddComponentMenu("Nirvana/UI/Bind/Variable Bind Gray")]
    public class UIVariableBindGray : UIVariableBindBool
    {
        [HideInInspector]
        [SerializeField]
        [Range(0, 255)]
        private int enabledGray;
        [HideInInspector]
        [SerializeField]
        [Range(0, 255)]
        private int disabledGray =255;

        private UIGrayscale m_UIGrayscale;
        protected override void OnValueChanged()
        {
            if (m_UIGrayscale == null) m_UIGrayscale = GetComponent<UIGrayscale>();
            bool result = GetResult();
            m_UIGrayscale.GrayLerp = result ? enabledGray : disabledGray;
        }
    }
}

